using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sis.Entities;

namespace Sis.Repository.Mapping
{
    public class VentaRegistradaMap : EntityTypeConfiguration<VentaRegistrada>
    {
        public VentaRegistradaMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.TipoVenta)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.NSolicitud)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.FormaPago)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.NEquifax)
                .IsRequired()
                .HasMaxLength(15);

            this.Property(t => t.NVoucher)
                .IsRequired()
                .HasMaxLength(11);

            this.Property(t => t.NDeposito)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.DniRuc)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.ApPaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.ApMaterno)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Nombres)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Marca)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Modelo)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.Nomenclatura)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.NTelefonico)
                .IsRequired()
                .HasMaxLength(9);

            // Table & Column Mappings
            this.ToTable("VentaRegistrada");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.FechaVenta).HasColumnName("FechaVenta");
            this.Property(t => t.TipoVenta).HasColumnName("TipoVenta");
            this.Property(t => t.NSolicitud).HasColumnName("NSolicitud");
            this.Property(t => t.FormaPago).HasColumnName("FormaPago");
            this.Property(t => t.IdPromotor).HasColumnName("IdPromotor");
            this.Property(t => t.NEquifax).HasColumnName("NEquifax");
            this.Property(t => t.NVoucher).HasColumnName("NVoucher");
            this.Property(t => t.NDeposito).HasColumnName("NDeposito");
            this.Property(t => t.DniRuc).HasColumnName("DniRuc");
            this.Property(t => t.ApPaterno).HasColumnName("ApPaterno");
            this.Property(t => t.ApMaterno).HasColumnName("ApMaterno");
            this.Property(t => t.Nombres).HasColumnName("Nombres");
            this.Property(t => t.Marca).HasColumnName("Marca");
            this.Property(t => t.Modelo).HasColumnName("Modelo");
            this.Property(t => t.Nomenclatura).HasColumnName("Nomenclatura");
            this.Property(t => t.NTelefonico).HasColumnName("NTelefonico");
            this.Property(t => t.PrecioPrepago).HasColumnName("PrecioPrepago");
            this.Property(t => t.PrecioVenta).HasColumnName("PrecioVenta");
            this.Property(t => t.NIndPostpago).HasColumnName("NIndPostpago");
            this.Property(t => t.NIndPrepago).HasColumnName("NIndPrepago");
            this.Property(t => t.NIndChip).HasColumnName("NIndChip");
            this.Property(t => t.NInPortabilidad).HasColumnName("NInPortabilidad");

            // Relationships
            this.HasRequired(t => t.Promotor)
                .WithMany(t => t.VentaRegistradas)
                .HasForeignKey(d => d.IdPromotor);

        }
    }
}
